package com.yonyougov.devops.cruxcisupport.envversionhistory;

import com.yonyougov.devops.cruxcisupport.envversionhistory.vo.EnvVersionHistoryPageLikeDto;
import com.yonyougov.devops.cruxcisupport.envversionhistory.vo.EnvVersionHistoryPageLikeVo;
import com.yonyougov.devops.fwc.core.dao.BaseDao;
import com.yonyougov.devops.fwc.core.entity.Pagination;
import com.yonyougov.devops.fwc.core.service.impl.BaseServiceImpl;
import org.springframework.stereotype.Service;

import java.math.BigInteger;
import java.util.List;

/**
 * 环境应用版本历史表服务实现
 * 历史模块->版本历史
 */
@Service
public class EnvVersionHistoryServiceImpl extends BaseServiceImpl<EnvVersionHistoryEntity, BigInteger> implements EnvVersionHistoryService {
    private final EnvVersionHistoryDao envVersionHistoryDao;

    public EnvVersionHistoryServiceImpl(EnvVersionHistoryDao envVersionHistoryDao) {
        this.envVersionHistoryDao = envVersionHistoryDao;
    }

    @Override
    public BaseDao<EnvVersionHistoryEntity, BigInteger> getDao() {
        return envVersionHistoryDao;
    }


    //<!--用户自定义代码开始-->
    /**
     * 单表分页模糊查询
     * @param envVersionHistoryPageLikeDto 查询条件
     * @return Pagination<EnvVersionHistoryPageLikeRespVo>
     * @Date 2020年4月10日11:07:57
     */
    @Override
    public Pagination<EnvVersionHistoryPageLikeVo> findByEnvVersionHistoryPageLike(EnvVersionHistoryPageLikeDto envVersionHistoryPageLikeDto) {

        List<EnvVersionHistoryPageLikeVo> singlePageLikeList = envVersionHistoryDao.findByEnvVersionHistoryPageLike(envVersionHistoryPageLikeDto);
        int totalCount = envVersionHistoryDao.countByEnvVersionHistoryLike(envVersionHistoryPageLikeDto);

        return new Pagination<EnvVersionHistoryPageLikeVo>(envVersionHistoryPageLikeDto.getMax(), envVersionHistoryPageLikeDto.getPageNum(),totalCount,singlePageLikeList);
    }
    //<!--用户自定义代码结束-->
}
